//
//  IVCSSDK.h
//  ivcs_ios_demo
//
//  Created by zealcomm user on 2020/10/21.
//  Copyright © 2020 zealcomm user. All rights reserved.
//
#import <Foundation/Foundation.h>

//! Project version number for IvcsCustomer.
FOUNDATION_EXPORT double IvcsCustomerVersionNumber;

//! Project version string for IvcsCustomer.
FOUNDATION_EXPORT const unsigned char IvcsCustomerVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <IvcsCustomer/PublicHeader.h>

#import <Foundation/Foundation.h>
#import <AVFoundation/AVCaptureDevice.h>
#import <IVCS/IVCS.h>
#import "IvcsCustomerDelegate.h"

NS_ASSUME_NONNULL_BEGIN

// 媒体类型
typedef NS_OPTIONS(NSInteger, MediaType) {
    MediaTypeUnknown = 0,
    MediaTypeAudio = 1 << 0,
    MediaTypeVideo = 1 << 1,
};

@interface IvcsCustomer : NSObject

@property (nonatomic,strong) id<IvcsCustomerDelegate> delegate;

declareSingleInstance(Customer)

/// 访客初始化并连接 CCS
/// @param serviceUrl 账号系统的后台地址
/// @param name 访客登录用户名
/// @param password 访客登录密码
/// @param org 访客所属机构名
/// @param mediaOptions 访客视频流的设置
/// @param onSuccess 初始化成功，返回用户基本信息
/// @param onFailure 初始化失败，返回错误信息
-(void)initWithServiceUrl:(NSString *)serviceUrl
        name:(NSString *)name
        password:(NSString *)password
        org:(NSString *)org
        mediaOptions:(MediaStreamSettingOptions *__nullable)mediaOptions
        onSuccess:(void (^)(ZcoModelUserInfo *userInfo))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发起视频呼叫
/// @param serviceId 坐席分组 id
/// @param formId 用户资料表单 id 没有的话传 0 即可
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)requestSession:(NSInteger)serviceId withFormId:(NSInteger) formId onSuccess:(void (^)(ZcoModelSessionInfo *sessionInfo))onSuccess
       onFailure:(void (^)(NSError *error))onFailure;

/// 退出会话
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)quitSession:(void (^)(void))onSuccess
                onFailure:(void (^)(NSError *error))onFailure;



/// 音视频加入会话
/// @param label 本端流标签
/// @param view 用于显示流的 view
/// @param onSuccess 成功，返回本端流
/// @param onFailure 失败
-(void)startVideoWithLabel:(nonnull NSString *)label andRenderView:(IRTCCameraPreviewView *)view
                   onSuccess:(void (^)(void))onSuccess
                   onFailure:(void (^)(NSError *error))onFailure;




/// 订阅并渲染远端流
/// @param label 流标签
/// @param view 渲染的控件
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)renderStreamWithLabel:(nonnull NSString *)label
                   renderView:(NSObject<IRTCVideoRenderer>*)view
                   onSuccess:(void (^)(void))onSuccess
                   onFailure:(void (^)(NSError *error))onFailure;

/// 绑定特定 label 的流（已订阅或本地流）到 view
/// @param label 流标签
/// @param view 渲染的控件
-(void)attachStreamWithLabel:(nonnull NSString *)label
                   renderView:(NSObject<IRTCVideoRenderer> *)view;

/// 从 view 上解除特定 label 的流
/// @param label 流标签
/// @param view 渲染的控件
-(void)detachStreamWithLabel:(nonnull NSString *)label
                   renderView:(NSObject<IRTCVideoRenderer> *)view;


/// 切换摄像头
- (void)switchCameraOnSuccess:(nullable void (^)(void))onSuccess onFailure:(nullable void (^)(NSError * _Nonnull))onFailure;

/// 停止本地视频的声音/视频画面推送
/// @param type audio/video
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)muteWithMediaType:(MediaType)type
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;


/// 恢复本地视频的声音/视频画面推送
/// @param type audio/video
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)unmuteWithMediaType:(MediaType)type
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;

/// 分享url资源文件给对方
/// @param type 资源类型 ['doc','pic','video','aduio','page','paper']
/// @param url 资源地址
/// @param name 资源名字
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type
                 resourceUrl:(NSString *)url
                 resourceName:(NSString *)name
                 toRoles:(NSString *)roles
                 onSuccess:(void (^)(void))onSuccess
                 onFailure:(void (^)(NSError *error))onFailure;


/// 分享资源文件
/// @param type 文件类型  ['doc','pic','video','aduio','page','paper']
/// @param uploadUrl 上传的url
/// @param fileData fileData
/// @param fileName 文件名
/// @param mimeType 文件类型
/// @param roles 发送给对方的角色 默认是agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type
            uploadUrl:(NSString *)uploadUrl
            fileData:(NSData *)fileData
            fileName:(NSString *)fileName
            mimeType:(NSString *)mimeType
            toRoles:(NSString *)roles
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;


/// 发送自定义消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers , 默认是 agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendCustomMessage:(id)data
        toRoles:(NSString * __nullable)roles
        onSuccess:(void (^__nullable)(void))onSuccess
        onFailure:(void (^__nullable)(NSError *error))onFailure;


/// 发送文本消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers, 默认是 agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendTextMessage:(NSString *)data
        toRoles:(NSString * __nullable)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发送消息确认
/// @param data 消息确认的信息体
/// @param roles 发送给的角色 默认是“agents”
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendMessageConfirmation:(ZcoModelConfirmData *)data
        toRoles:(NSString * __nullable)roles
        onSuccess:(void (^ __nullable)(void))onSuccess
        onFailure:(void (^ __nullable)(NSError *error))onFailure;

/// 发送截屏消息
/// @param imageUrl 图片的url地址
/// @param roles 发送给的角色 默认是“agents”
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendSnapshotMessage:(NSString *)imageUrl toRoles:(NSString * __nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^ __nullable)(NSError * _Nonnull error))onFailure;

/// 发送表单消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendFormData:(NSDictionary *)data
        toRoles:(NSString * __nullable)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

/// 发送指令
/// @param cmd 指令
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
- (void)sendPeerCMD:(ZcoModelCMD *)cmd to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 取消指令
/// @param cmd 指令
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
- (void)sendPeerCancel:(ZcoModelCMD *)cmd to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 响应指令
/// @param cmd 指令
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
- (void)sendPeerResponse:(ZcoModelCMD *)cmd to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 发送手写签名消息(这里使用的是 fabric3.4 方案
/// @param roles 发送给角色 agents/customers(默认 agents)
- (void)sendHandWritingMessage:(NSString * _Nullable)msg to:(NSString *__nullable)roles;

#warning TODO 对接 ai 客服使用
/// 坐席发送用户信息，用户确认
/// @param sessionId sessionId
/// @param url 确认信息的url地址
/// @param userInfo 用户信息
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sureUserInfoWithSessionId:(NSString *)sessionId
        url:(NSString *)url
        userInfo:(NSMutableDictionary *)userInfo
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

#warning TODO parameter 待封装
/// 上传表单数据
/// @param sessionId 会话id
/// @param url 上传url
/// @param parameter 参数
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)uploadFormDataWithSessionId:(NSString *)sessionId
                        url:(NSString *)url
                        parameter:(NSMutableDictionary *)parameter
                        onSuccess:(void (^)(id))onSuccess
                        onFailure:(void (^)(NSError *error))onFailure;

/// 获取已启用的业务分组
-(void)getScenarios:(void (^)(NSArray<ZcoModelSessionInfo*> *))onSuccess
          onFailure:(void (^)(NSError * _Nonnull))onFailure;

-(CGSize)getVideoSizeByVideoLable:(NSString *)videoLabel;

/// 会话结束后释放 ivcs 所占用的所有资源
-(void)releaseAll;

/// 获取本地视频流的快照
-(void)getSnapShotImage:(void (^)(UIImage*))onSuccess onFailure:(void (^)(NSError*))onFailure;

/// 确认坐席收集的信息
-(void)confirmCollect:(NSDictionary *)data onSuccess:(void (^)(CallBackObject *_Nonnull))onSuccess
            onFailure:(void (^)(NSError * _Nonnull))onFailure;

/// 更新收集信息的表单
-(void)updateCollectForm:(NSInteger) formId onSuccess:(void (^)(id))onSuccess
               onFailure:(void (^)(NSError * _Nonnull))onFailure;

@end

NS_ASSUME_NONNULL_END
